//数据源格式
import axios from '../util/request';

// 电梯
/*
   "guid": "1234567",                  //数据唯一ID
    "state": 1,                          //状态四种  0：Flaw Detected 检测到缺陷；1：Passenger Trapped 乘客被困；2:Under Maintemance足；3：Working 正常
    "liftaddress": "Block 10A-A",       //地址
    "lat":"1.28635847107696",
    "lon":"103.842917174799",
    "towncuncil": "Tanjongxxxx",        //所在楼宇地址
    "landingslocation": "1,2,xxxx",        //平台位置？
    "motorroomlocation":"Rooftop",      //马达位置
    "maintenancecompany":"FUJI"     //维护公司

    state随机策略：
    $rand = rand(0, 100);
    if($rand > 40) return 3; //正常
    if($rand > 20) return 2; //维修不足
    if($rand > 10) return 0; //监测到缺陷
    return 1; //乘客被困
*/
export async function getLift() {
  return await axios({
    url: '/data/lift',
    method: 'get',
  }).then(res => res.data)
}

// 绿色建筑
/*"guid": "1234567",                  //数据唯一ID
"name": "xxxxxx",       //建筑名字
"postalcode": "xxxxxxx",    //邮编
"lat":"1.28635847107696",
"lon":"103.842917174799",
"imageurl": "http:xxxxx",        //缩略图
"awardachieved": "Platinum"       //评级
*/
export async function getGreenBuilding(url, query) {
  const data = await axios({
    url: '/data/gb',
    method: 'get',
  }).then(res => res.data)
  return data
}
// 路况实时摄像头影像
export async function getCameraImage(url, query) {
  const data = await axios({
    url: '/data/camera',
    method: 'get',
  }).then(res => res.data)
  return data
}

// 实时交通数据
export async function getTrafficSpeed(url, query) {
  return await axios({
    url: '/data/speed',
    method: 'get',
  }).then(res => res.data);
}

//桥梁数据
export async function getBridge(url, query) {
  return await axios({
    url: '/data/bridge',
    method: 'get',
  }).then(res => res.data);
}

// Campus数据
export async function getCampus(url, query) {
  const data = await axios({
    url: '/data/campus',
    method: 'get',
  }).then(res => res.data)
  return data
}
//洪水数据
export async function getFlood(url, query) {
  const data = await axios({
    url: '/data/flood',
    method: 'get',
  }).then(res => res.data)
  return data
}